<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/16
 * Time: 18:32
 */
namespace library\core;

/**
 * db连接初始化类
 * Class db_conn
 * @author zhangcn <wecontact@foxmail.com>
 */
abstract class db_conn
{
    /**
     * db_conn constructor.
     */
    public function __construct()
    {
        $env = config::get('env');
        $driver = config::get('driver');
        $config = config::get("{$env}.{$driver}");
        $config['driver'] = $driver;

        try{
            require 'vendor/autoload.php';
            $this->db = new \Dibi\Connection($config);
        }catch (\Exception $e){
            if ($env == 'production') {
                echo $e->getMessage();
                die();
            }
        }
    }
}